Code
import numpy as np
import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt
import seaborn as sns
# Updated imports from the PySAL ecosystem
from libpysal.weights import KNN, Queen # For spatial weights
from esda.moran import Moran, Moran_Local # For Moran's I tests
import matplotlib.pyplot as plt
import contextily as ctx
import geopandas as gpd
from splot.libpysal import plot_spatial_weights
from libpysal.weights import DistanceBand
from splot.esda import moran_scatterplot
from esda.moran import Moran_Local
from splot.esda import lisa_cluster
from shapely.geometry import Point
from spreg import ML_Lag
from sklearn.cluster import KMeans
from sklearn.preprocessing import StandardScaler
import warnings
warnings.filterwarnings( "ignore" )